#ifndef CMAINWINDOW_H
#define CMAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
#include <QDateTime>
#include <QLineEdit>
#include "VSession.h"

namespace Ui {
class CMainWindow;
}

class CMainWindow : public QMainWindow
{
    Q_OBJECT
    explicit CMainWindow(QWidget *parent = nullptr);
    ~CMainWindow();
public:
    static CMainWindow *getInstance();

    void init();

    void hSplitSession(QString strId); //空Id 新建
    void vSplitSession(QString strId);
public slots:
    void slotSendBytes(int nBytes);
    void slotRecvBytes(int nBytes);
    void slotTextCode(QString strTextCode);

    void slotSaveSession();
    void slotCloseSession();
    void slotRemoveSession();

    void slotShowHistory(bool bNone);
    void slotSelectSession(QString strId);
signals:
    void sigRecount();
protected:
    bool eventFilter(QObject *watched, QEvent *event);
private:
    void initMenu();
    void initToolBar();
    void initStatusBar();

    void refreshHistory(); //刷新历史会话
private:
    Ui::CMainWindow *ui;

    VSession *m_pSelectedSession = nullptr; //选中的会话
    //
    QToolBar *m_pNameToolBar = nullptr;
    //状态栏
    QLabel *m_pTextCodeLabel = nullptr;
    QLabel *m_pSendLabel = nullptr;
    QLabel *m_pRecvLabel = nullptr;
    QPushButton *m_pBtnRecount = nullptr;
    QLineEdit *m_pSessionName = nullptr;

    QList<QAction *> m_listHistory;
};

#endif // CMAINWINDOW_H
